package com.tmeone.erpone.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tmeone.erpone.entity.Product;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tmeone.erpone.entity.TProduct;
import com.tmeone.erpone.mapper.TProductMapper;
import com.tmeone.erpone.service.ITProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tmeone
 * @since 2021-04-19
 */
@Service
public class TProductServiceImpl extends ServiceImpl<TProductMapper, TProduct> implements ITProductService {

    @Autowired
    private TProductMapper productMapper;
    //商品分页
    @Override
    public IPage<Product> pageProducts(IPage<Product> page) {
        return productMapper.pageProducts(page);
    }

    @Override
    public List<Product> selectProductById(String id) {
        return productMapper.selectProductById(id);
    }

    /**
     * 获取供应商商品
     * 作者：wzs
     * @param page 分页参数
     * @param search 查询关键字
     * @param companyId 供应商公司id
     * @return 供应商商品
     */
    @Override
    public IPage<TProduct> selectSupplierProductPage(Page page, String search, String companyId) {
        return productMapper.selectSupplierProductPage(page,search,companyId);
    }

    /**
     * 获取所有供应商商品
     * @param page 分页参数
     * @param search 查询关键字
     * @param userId 用户id
     * @return 供应商商品
     */
    @Override
    public IPage<TProduct> selectSupplierAllProductPage(Page page, String search, String userId) {
        return productMapper.selectSupplierAllProductPage(page,search,userId);
    }
    //根据compan_id查询所有商品
    @Override
    public List<TProduct> getProductByCustomerId(String id) {
        return productMapper.selectAllProduct(id);
    }
}
